package com.swanclouds.redfish.internal;

import com.swanclouds.api.types.ServiceType;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.common.redfish.CollectionResource;
import com.swanclouds.redfish.common.redfish.CollectionResourceModel;

/**
 * Author: HuangFuYuHui
 * Title: BaseUpdateService
 * Description: 升级服务资源
 * Date: 2022/7/27 10:56
 */
public class BaseUpdateService extends BaseRedfishService {

    public BaseUpdateService() {
        super(ServiceType.UPDATES);
    }

    private static ThreadLocal<String> updatesContainer = new ThreadLocal<>();

    public String getUpdateId() {
        if (updatesContainer.get() != null) {
            return updatesContainer.get();
        }
        CollectionResource resource = get(CollectionResourceModel.class, uri(ClientConstants.PATH_UPDATESERVICE)).execute();
        return getResourceId(resource, updatesContainer);
    }
}
